home *** CD-ROM | disk | FTP | other *** search
-
- {************************************************************************}
- {* *}
- {* VB Main Procedures -- Block 3 *}
- {* *}
- {* AddWordList DeleteWordList EditWordList *}
- {* MakeWordList PrintWordList RenameWordList *}
- {* StudyWordList TestWordList *}
- {* *}
- {************************************************************************}
-
-
- overlay procedure AddWordList;
- { add words to an existing list }
- var
- AddListName : ListName;
- AddArray : WordList;
- NumberOfPairs : integer;
- i : integer;
- begin
- PrintPageHeader('Add To a List');
- writeln;
- AskDir;
- writeln;
- GetListName (AddListName,'enlarge',1);
- if length(AddListName) > 0
- then
- begin
- ReadList(NumberOfPairs,AddArray,AddListName);
- if NumberOfPairs > 0
- then
- begin
- if NumberOfPairs < 25
- then
- begin
- repeat
- writeln;
- spaces(5);
- i := succ(NumberOfPairs);
- write (i:2,'. Enter an English word: ');
- readln (AddArray[i].EnglishWord);
- if length(AddArray[i].EnglishWord) > 0
- then
- begin
- NumberOfPairs := succ(NumberOfPairs);
- repeat
- spaces(10);
- write ('And the ',Language,' translation: ');
- readln (AddArray[i].ForeignWord);
- if length(AddArray[i].ForeignWord) = 0
- then
- Beep
- until length(AddArray[i].ForeignWord) > 0;
- writeln
- end;
- if NumberOfPairs in [4,8,12,16,20,24]
- then
- PrintPageHeader('Add To a List')
- until (length(AddArray[i].EnglishWord) = 0) or (NumberOfPairs = 25);
- writeln;
- WriteList (NumberOfPairs,AddArray,AddListName)
- end
- else
- begin
- spaces(12);
- writeln ('That list is full.');
- pause
- end
- end
- else
- pause
- end
- end;
-
-
- overlay procedure DeleteWordList;
- { delete a word list }
- var
- More : boolean;
- DelListName : ListName;
- DelFileName : FileName;
- DelFile : ListFile;
- i : integer;
- begin
- More := TRUE;
- while More do
- begin
- PrintPageHeader('Delete a List');
- writeln;
- AskDir;
- writeln;
- GetListName (DelListName,'delete',1);
- if length(DelListName) > 0
- then
- begin
- writeln;
- if ask ('Delete ' + DelListName)
- then
- begin
- writeln;
- for i := 1 to length (DelListName) do
- DelListName[i] := UpCase(DelListName[i]);
- DelFileName := DelListName + '.' + Extent;
- assign (DelFile,DelFileName);
- {$I-} erase (DelFile) {$I+};
- if IOresult = 0
- then
- begin
- writeln;
- More := ask('Would you like to delete any other lists')
- end
- else
- begin
- writeln;
- More := ask('I couldn''t find that list. Do you want to try again')
- end
- end
- else
- begin
- writeln;
- More := ask('Would you like to delete any other lists')
- end
- end
- else
- More := FALSE
- end
- end;
-
-
- overlay procedure EditWordList;
- { edit an existing list }
- var
- EditListName : ListName;
- EditArray : WordList;
- NumberOfPairs : integer;
- TempWord : FullWord;
- i,j : integer;
- More : boolean;
- begin
- More := TRUE;
- while More do
- begin
- PrintPageHeader('Edit a List');
- writeln;
- AskDir;
- writeln;
- GetListName (EditListName,'edit',1);
- if length(EditListName) > 0
- then
- begin
- ReadList (NumberOfPairs,EditArray,EditListName);
- if NumberOfPairs > 0
- then
- begin
- writeln;
- SetPage('Edit a List',14,'Current Word',18,
- 'Replacement (CR to leave as is)');
- writeln;
- writeln;
- for i := 1 to NumberOfPairs do
- begin
- j := (40 - length (EditArray[i].EnglishWord)) div 2;
- spaces (j);
- write (EditArray[i].EnglishWord);
- spaces (j + 5);
- readln (TempWord);
- if length (TempWord) > 0
- then
- EditArray[i].EnglishWord := copy(TempWord,1,length(TempWord));
- j := (40 - length (EditArray[i].ForeignWord)) div 2;
- spaces (j);
- write (EditArray[i].ForeignWord);
- spaces (j + 5);
- readln (TempWord);
- if length (TempWord) > 0
- then
- EditArray[i].ForeignWord := copy(TempWord,1,length(TempWord));
- writeln;
- if i in [4,8,12,16,20,24]
- then
- begin
- writeln;
- SetPage('Edit a List',14,'Current Word',18,
- 'Replacement (CR to leave as is)');
- writeln;
- writeln
- end
- end;
- writeln;
- WriteList (NumberOfPairs,EditArray,EditListName)
- end
- end
- else
- More := FALSE;
- writeln;
- if More then
- More := ask ('Would you like to edit another list')
- end
- end;
-
-
- overlay procedure MakeWordList;
- { construct a word list file }
- var
- NumberOfPairs : integer;
- i : integer;
- Name : ListName;
- Pair : WordPair;
- FileID : ListFile;
- NameOfFile : FileName;
- begin
- PrintPageHeader('Make a Word List');
- writeln;
- GetListName(Name,'What would you like to call this list',2);
- if length(Name) > 0
- then
- begin
- writeln;
- NumberOfPairs := 0;
- for i := 1 to length(Name) do
- Name[i] := UpCase(Name[i]);
- NameOfFile := Name + '.' + Extent;
- if not (ExistFile(FileID,NameOfFile))
- then
- begin
- {$I-} rewrite (FileID) {$I+};
- if IOresult = 0
- then
- begin
- repeat
- spaces(5);
- i := succ(NumberOfPairs);
- write (i:2,'. ');
- write ('Enter an English word: ');
- readln (Pair.EnglishWord);
- if length(Pair.EnglishWord) > 0
- then
- begin
- NumberOfPairs := succ(NumberOfPairs);
- repeat
- spaces(10);
- write ('And the ',Language,' translation: ');
- readln (Pair.ForeignWord);
- if length(Pair.ForeignWord) = 0
- then
- Beep
- until length(Pair.ForeignWord) > 0;
- writeln;
- write (FileID,Pair)
- end;
- if NumberOfPairs in [4,8,12,16,20,24]
- then
- begin
- PrintPageHeader('Make a Word List');
- writeln
- end
- until (length(Pair.EnglishWord) = 0) or (NumberOfPairs = 25);
- close (FileID);
- writeln;
- spaces (10);
- writeln ('Word list ',Name,', with ',NumberOfPairs,
- ' pairs of words, has been created.');
- pause
- end
- else
- begin
- writeln;
- spaces(10);
- center ('There are too many directory entries to open ' +
- NameOfFile,TRUE);
- pause
- end
- end
- else
- begin
- writeln;
- spaces(12);
- writeln('The list ',Name,' already exists.');
- pause
- end
- end
- end;
-
-
- overlay procedure PrintWordList;
- { print a word list }
- var
- More : boolean;
- PrintListName : ListName;
- PrintArray : WordList;
- i : integer;
- NumberOfPairs : integer;
- LengthE : integer;
- LengthF : integer;
- LengthL : integer;
- Indent : integer;
- begin
- More := TRUE;
- while More do
- begin
- PrintPageHeader('Print a List');
- writeln;
- AskDir;
- writeln;
- GetListName (PrintListName,'print',1);
- if length(PrintListName) > 0
- then
- begin
- ReadList(NumberOfPairs,PrintArray,PrintListName);
- if NumberOfPairs > 0
- then
- begin
- LengthE := 0; LengthF := 0;
- for i := 1 to NumberOfPairs do
- begin
- if length(PrintArray[i].EnglishWord) > LengthE
- then LengthE := length(PrintArray[i].EnglishWord);
- if length(PrintArray[i].ForeignWord) > LengthF
- then LengthF := length(PrintArray[i].ForeignWord);
- end;
- LengthL := LengthE + LengthF + 5;
- Indent := (LengthL - length(PrintListName)) div 2;
- writeln (LST);
- writeln (LST); write (LST,' ');
- for i := 1 to Indent do write (LST,' ');
- writeln (LST,PrintListName);
- writeln (LST);
- for i := 1 to NumberOfPairs do
- begin
- write (LST,' ');
- writeln (LST,pad(PrintArray[i].EnglishWord,LengthE),
- PrintArray[i].ForeignWord)
- end;
- write (LST,chr(FF))
- end;
- writeln;
- more := ask('Would you like to print another list')
- end
- else
- More := FALSE
- end
- end;
-
-
- overlay procedure RenameWordList;
- { rename word lists }
- var
- NewFile : ListFIle;
- OldFileName,
- NewFileName : FileName;
- OldListName,
- NewListName : ListName;
- More : boolean;
- i : integer;
- begin
- More := TRUE;
- while More do
- begin
- PrintPageHeader('Rename a List');
- writeln;
- AskDir;
- writeln;
- GetListName(OldListName,'rename',1);
- if length (OldListName) > 0
- then
- begin
- writeln;
- repeat
- GetListName(NewListName,'What would you like to call it',2);
- if length(NewListName) = 0
- then
- Beep
- until length(NewListName) > 0;
- writeln;
- if ask('Rename ' + OldListName + ' to ' + NewListName)
- then
- begin
- writeln;
- for i := 1 to length (OldListName) do
- OldListName[i] := UpCase(OldListName[i]);
- for i := 1 to length (NewListName) do
- NewListName[i] := UpCase(NewListName[i]);
- writeln;
- OldFileName := OldListName + '.' + Extent;
- NewFileName := NewListName + '.' + Extent;
- assign (NewFile,OldFileName);
- {$I-} rename(NewFile,NewFileName) {$I+};
- if IOresult = 0
- then
- more := ask('Would you like to rename other lists')
- else
- more := ask('I couldn''t find that list. Do you want to try again');
- close (NewFile)
- end
- else
- begin
- writeln;
- writeln;
- More := ask('Would you like to rename other lists')
- end
- end
- else
- More := FALSE
- end
- end;
-
-
- overlay procedure StudyWordList;
- { study a word list }
- var
- StudyListName : ListName;
- NumberOfPairs : integer;
- NumberCorrect : integer;
- StudyArray : WordList;
- Order : Ordering;
- EnglishFirst : boolean;
- TempWord : FullWord;
- WordA, WordB : FullWord;
- i, j : integer;
-
- procedure WordOkay;
- { if they got it right }
- const
- OKMessage : array[1..23] of FullWord =
- ( 'Correct!' , 'That''s right!' , 'Fantastic!' , 'Super!' ,
- 'You''re a champ!' , 'Pure genius!' , 'Brilliant!' , 'All right!' ,
- 'Wowee!' , 'That''s the way!' , 'Right again!' , 'Wonderful!' ,
- 'Not bad!' , 'Yes!' , 'That''s it!' , 'Exactly right!' ,
- 'Flawless!' , 'Precisely!' , 'Absolutely!' , 'I''m impressed!' ,
- 'Awesome!' , 'Fabulous!' , 'What a touch!' );
- var
- i : integer;
- begin
- randomize;
- i := random(23) + 1;
- writeln;
- center(OKMessage[i],TRUE);
- delay(Time)
- end;
-
- procedure WordWrong(Word : FullWord);
- { if they got it wrong }
- const
- NotOKMessage : array [1..14] of FullWord =
- ( 'You''ll have to work on that one.' , 'Close, but not quite.' ,
- 'Oops.' , 'No, sorry.' ,
- 'Hmmm. Not quite.' , 'I''m afraid not.' ,
- 'Nope. That''s not it.' , 'Almost.' ,
- 'You missed that one.' , 'Darn it.' ,
- 'Not quite.' , 'Shucks.' ,
- 'Whoops.' , 'Sorry about that.' );
- var
- TempW : FullWord;
- i : integer;
- begin
- repeat
- randomize;
- i := random(14) + 1;
- writeln;
- center(NotOKMessage[i],TRUE);
- writeln;
- writeln;
- delay(Time);
- spaces(10);
- writeln ('The correct translation is: ',Word);
- spaces(10);
- write ('Please type it in now: ');
- readln (TempW)
- until (TempW = Word)
- end;
-
- begin { StudyWordList }
- PrintPageHeader('Study a List');
- writeln;
- AskDir;
- writeln;
- GetListName (StudyListName,'study',1);
- if length (StudyListName) > 0
- then
- begin
- ReadList(NumberOfPairs,StudyArray,StudyListName);
- if NumberOfPairs > 0
- then
- begin
- SetRandomOrder(Order,NumberOfPairs);
- EnglishFirst := SetSequence(FALSE);
- NumberCorrect := 0;
- for i := 1 to NumberOfPairs do
- begin
- SetPage('Study a List',10,' ',33,'Translation');
- writeln;
- writeln;
- if EnglishFirst
- then
- begin
- WordA := StudyArray[Order[i]].EnglishWord;
- WordB := StudyArray[Order[i]].ForeignWord
- end
- else
- begin
- WordA := StudyArray[Order[i]].ForeignWord;
- WordB := StudyArray[Order[i]].EnglishWord
- end;
- j := (40 - length(WordA)) div 2;
- spaces (j);
- write (WordA);
- spaces(j + 6);
- readln (TempWord);
- if TempWord = WordB
- then
- begin
- WordOkay;
- NumberCorrect := succ(NumberCorrect)
- end
- else
- WordWrong(WordB)
- end;
- StudyReport(NumberOfPairs,NumberCorrect,FALSE,StudyArray,
- StudyListName,Order)
- end
- end
- end;
-
-
- overlay procedure TestWordList;
- { test for mastery of a list }
- var
- TestListName : ListName;
- NumberOfPairs : integer;
- NumberCorrect : integer;
- TestArray : WordList;
- Order : Ordering;
- EnglishFirst : boolean;
- TempWord : FullWord;
- WordA, WordB : FullWord;
- i, j : integer;
- MissFlag : Ordering;
- Rand : boolean;
- begin
- Rand := FALSE;
- PrintPageHeader('Testing For Mastery');
- writeln;
- AskDir;
- writeln;
- GetListName (TestListName,'try',1);
- if length (TestListName) > 0
- then
- begin
- ReadList(NumberOfPairs,TestArray,TestListName);
- if NumberOfPairs > 0
- then
- begin
- SetRandomOrder(Order,NumberOfPairs);
- EnglishFirst := SetSequence(TRUE);
- if Response in ['R','r']
- then
- Rand := TRUE;
- NumberCorrect := 0;
- for i := 1 to NumberOfPairs do
- begin
- MissFlag[Order[i]] := 0;
- if Rand
- then
- begin
- randomize;
- EnglishFirst := ((random(2) + 1) = 1)
- end;
- SetPage('Testing For Mastery',10,' ',33,'Translation');
- writeln;
- writeln;
- if EnglishFirst
- then
- begin
- WordA := TestArray[Order[i]].EnglishWord;
- WordB := TestArray[Order[i]].ForeignWord
- end
- else
- begin
- WordA := TestArray[Order[i]].ForeignWord;
- WordB := TestArray[Order[i]].EnglishWord
- end;
- j := (40 - length(WordA)) div 2;
- spaces (j);
- write (WordA);
- spaces(j + 6);
- readln (TempWord);
- if TempWord = WordB
- then
- NumberCorrect := succ(NumberCorrect)
- else
- MissFlag[Order[i]] := 1
- end;
- StudyReport(NumberOfPairs,NumberCorrect,TRUE,TestArray,
- TestListName,MissFlag)
- end
- end
- end;
-
-